package com.leetcode.LC;

public class LC520 {

    public boolean detectCapitalUse(String word) {
        if (word.length()<2){
            return true;
        }
        int a ;
        if (word.charAt(0) >= 'A' && word.charAt(0) <= 'Z' && word.charAt(1) >= 'A' && word.charAt(1) <= 'Z') {
            a = 1;
            while (a < word.length()) {
                if (!(word.charAt(a) >= 'A' && word.charAt(a) <= 'Z')) {
                    return false;
                }
                a++;
            }
        } else if (word.charAt(0) >= 'A' && word.charAt(0) <= 'Z' && word.charAt(1) >= 'a' && word.charAt(1) <= 'z') {
            a = 1;
            while (a < word.length()) {
                if (word.charAt(a) >= 'A' && word.charAt(a) <= 'Z') {
                    return false;
                }
                a++;
            }
        } else if (word.charAt(0) >= 'a' && word.charAt(0) <= 'z') {
            a = 0;
            while (a < word.length()) {
                if (word.charAt(a) >= 'A' && word.charAt(a) <= 'Z') {
                    return false;
                }
                a++;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new LC520().detectCapitalUse("abC"));
    }
}
